<!doctype html>
<html class="no-js">
<head>
    <meta charset="UTF-8">
    <title>修改管理员 | 校园知事</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="format-detection" content="telephone=no">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="icon" type="image/x-icon" href="/favicon.ico">
    <link rel="stylesheet" href="/assets/css/amazeui.min.css" />
    <link rel="stylesheet" href="/assets/css/admin.css">
    <link rel="stylesheet" href="/assets/css/appadmin.css">
</head>
<body>
       {{template "admin/naver.html" .}}
        <div class="admin-content">
            <div class="admin-content-body">
                <div class="am-cf am-padding am-padding-bottom-0">
                    <div class="am-fl am-cf"><strong class="am-text-primary am-text-lg" style="color: #222222;">编辑管理员信息</strong> </div>
                </div>
                <hr />
                <div class="am-g">
                    <div class="am-u-sm-12 am-u-md-8">
                        <form class="am-form am-form-horizontal">
                        <input type="hidden" id="id" value="{{.User.Id}}">
                            <div class="am-form-group">
                                <label for="num" class="am-u-sm-3 am-form-label">账号</label>
                                <div class="am-u-sm-9">
                                    <input type="text" id="num"  disabled="disabled" maxlength="16" value="{{.User.Num}}">
                                </div>
                            </div>
                            <div class="am-form-group">
                                <label for="name" class="am-u-sm-3 am-form-label">管理员姓名</label>
                                <div class="am-u-sm-9">
                                    <input type="tel" id="name" maxlength="20" placeholder="请输入管理员姓名" value="{{.User.Username}}">
                                </div>
                            </div>
                            <div class="am-form-group">
                                <label for="phone" class="am-u-sm-3 am-form-label">手机号码</label>
                                <div class="am-u-sm-9">
                                    <input type="text" id="phone" maxlength="12" placeholder="请输入手机号码" value="{{.User.Phone}}">
                                </div>
                            </div>
                             <div class="am-form-group">
                                <label for="email" class="am-u-sm-3 am-form-label">邮箱</label>
                                <div class="am-u-sm-9">
                                    <input type="email" id="email" maxlength="50" placeholder="请输入邮箱" value="{{.User.Email}}">
                                </div>
                            </div>
                            <div class="am-form-group">
                                <div class="am-u-sm-9 am-u-sm-push-3">
                                    <button type="button" class="am-btn am-btn-primary" onclick="changeUserInfo()">保存修改</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
      {{template "admin/footer.html" .}}
    <script type="text/javascript">
        function changeUserInfo() {
            var $id=$("#id");
            var $name=$("#name");
            if ($name.val().trim()==='') {
                layer.tips('请输入管理员姓名', $name);
                $name.focus();
                return ;
            }
            var $phone=$("#phone");
            var $email=$("#email");
            if ($email.val().trim().length>0) {
                if (!checkMail($email.val().trim())) {
                    layer.tips('请按正确的邮箱格式输入', $email);
                    $email.focus();
                    return ;
                }
            }
            $.lintul('/admin/user/uone',{id:$id.val().trim(),name:$name.val().trim(),phone:$phone.val().trim(),email:$email.val().trim()},function(data){
                 if (data.status === 1) {
                        layer.msg('修改成功', { offset: '15%', icon: 6 ,time:1000}, function () {
                            window.location.reload();
                        });
                    } else {
                        layer.msg('修改失败,请检查后重试', { offset: '15%', icon: 5 });
                    }
            });
        }
         function checkMail(mail) {
         var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
         if (filter.test(mail)) return true;
         return false;
        }
    </script>
</body>
</html>
